#define _CRT_SECURE_NO_WARNINGS

int sb(struct TreeNode* p, struct TreeNode* q)
{
    if (p == NULL && q != NULL)
        return -1;
    if (p != NULL && q == NULL)
        return -1;
    if (p == NULL && q == NULL)
        return 0;
    if (p->val != q->val)
        return -1;
    if (sb(p->left, q->left) == -1)
        return -1;
    if (sb(p->right, q->right) == -1)
        return -1;
    return 0;
}
bool isSameTree(struct TreeNode* p, struct TreeNode* q)
{
    int z = sb(p, q);
    if (z == -1)
        return false;
    else
        return true;
}